<?php

namespace App\Http\Requests\Admin\Panx\Device;

use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rule;

/**
 * @property string id
 * @property array skin_detector_ids
 * @property string account
 * @property string password
 */
class DeviceUpdateDeviceAccountRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id'                  => 'required|int|min:1|max:'.self::MAX_INT,
            'account'             => ['required', 'string', 'max:'.self::MAX_STRING, Rule::unique('device_accounts', 'account')->ignore($this->id)],
            'password'            => 'nullable|string|min:6|max:'.self::MAX_STRING,
            'skin_detector_ids'   => 'sometimes|required|array',
            'skin_detector_ids.*' => 'sometimes|int|min:1|max:'.self::MAX_INT,
        ];
    }
}
